package com.main;

import java.util.List;
import java.util.Scanner;  // 导入Scanner

import com.generator.Question;
import com.generator.QuestionGenerator;
import com.output.OutputHandler;

public class Main {
    public static void main(String[] args) {
        System.out.println("===== 加减乘除题目生成器 =====");
        
        // 1. 创建唯一的Scanner实例，供所有类共享
        Scanner scanner = new Scanner(System.in);
        
        // 2. 生成题目（将scanner传入QuestionGenerator，需修改其构造方法）
        QuestionGenerator generator = new QuestionGenerator(scanner);  // 传入scanner
        List<Question> questionList = generator.generateQuestions();
        
        // 3. 处理输出与CSV保存（将scanner传入OutputHandler）
        OutputHandler outputHandler = new OutputHandler(scanner);  // 传入scanner
        int columnCount = outputHandler.selectColumnCount();
        outputHandler.printQuestionsToConsole(questionList, columnCount);
        outputHandler.saveQuestionsToCSV(questionList, "math_questions.csv");
        
        // 4. 程序结束时，关闭唯一的Scanner
        scanner.close();
    }
}